package main

import (
	"fmt"
	"math"
)

func main() {
	var n, x int
	fmt.Scanf("%d %d", &n, &x)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scanf("%d", &arr[i])
	}
	flag := 1
	min := math.MaxInt64
	for i := 0; i < n; i ++ {
		for j := i + 1; j < n; j ++ {
			temp := arr[i] + arr[j]
			if temp >= x && temp <= min {
				flag = 0
				min = temp
			}

		}
	}
	if flag == 1 {
		min = x
	}
	fmt.Println(min)
}
